<?php

use Elite\Infrastructure\Server\Listener\Listener;

class OnCloseListener extends Listener {

    public function event() : string {
        return 'close';
    }

    public function callback() {
        $server = func_get_arg(0);
        $fd = func_get_arg(1);
        if (!$server->isEstablished($fd)) {
            return;
        }
        $fdHolder = $this->swoole->getFdHolder();
        $tk = $fdHolder->get($fd);
        $fdHolder->delete($tk);
        $fdHolder->delete($fd);
    }

}